import React from 'react';
import { Tooltip } from 'antd';
export const getBaseList = (data) => [
  {
    label: '数据库名称',
    value: data.databaseName,
    span: 8,
  },
  {
    label: '类型',
    value: data.databaseType,
    span: 8,
  },
  {
    label: '数据库地址',
    value: data.ipPort,
    span: 8,
  },
  {
    label: '用户名',
    value: data.userName,
    span: 8,
  },
  {
    label: '密码',
    value: data.password && data.password.split('').map(() => '*'),
    span: 8,
  },
  {
    label: '备注',
    value: data.remark,
    span: 8,
  },
];

export const getParamsColumns = () => [
  {
    dataIndex: 'name',
    title: '参数名',
  },
  {
    dataIndex: 'typeLabel',
    title: '类型',
  },
  {
    dataIndex: 'nonEmptyLabel',
    title: '必填',
  },
  {
    dataIndex: 'desc',
    title: '描述',
  },
];

export const getResultColumns = () => [
  {
    dataIndex: 'innerPath',
    title: '出参名',
  },
  {
    dataIndex: 'typeLabel',
    title: '类型',
  },
];

export const getMapColumns = () => [
  {
    dataIndex: 'thirdPath',
    title: '源key',
    width: 200,
    ellipsis: true,
    render: (text) => (
      <div style={{ wordWrap: 'break-word', wordBreak: 'break-word' }}>
        <Tooltip title={text} placement='topLeft'>
          {text}
        </Tooltip>
      </div>
    ),
  },
  {
    dataIndex: 'innerPath',
    title: '映射key',
    width: 200,
    ellipsis: true,
    render: (text) => (
      <div style={{ wordWrap: 'break-word', wordBreak: 'break-word' }}>
        <Tooltip title={text} placement='topLeft'>
          {text}
        </Tooltip>
      </div>
    ),
  },
  {
    dataIndex: 'typeLabel',
    title: '数据类型',
  },
  {
    dataIndex: 'isReturningLabel',
    title: '返回key(是否)',
  },
];
